/*
    Matali Physics Demo
    Copyright (c) 2011 KOMIRES Sp. z o. o.
 */
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using Komires.MataliPhysics;

namespace MataliPhysicsDemo
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>
    public class Wall
    {
        Demo demo;
        PhysicsScene scene;
        string instanceIndexName;

        public Wall(Demo demo, int instanceIndex)
        {
            this.demo = demo;
            instanceIndexName = " " + instanceIndex.ToString();
        }

        public void Initialize(PhysicsScene scene)
        {
            this.scene = scene;
        }

        public static void CreateShapes(Demo demo, PhysicsScene scene)
        {
        }

        public void Create(Vector3 objectPosition, Vector3 objectScale, Quaternion objectOrientation, string shapeName, int wallSize, Vector3 shapeSize, float density, bool enableSleeping)
        {
            Shape shape = scene.Factory.ShapeManager.Find(shapeName);

            PhysicsObject objectRoot = null;
            PhysicsObject objectBase = null;

            int instanceIndexCount = 0;

            objectRoot = scene.Factory.PhysicsObjectManager.Create("Wall" + instanceIndexName);

            objectBase = scene.Factory.PhysicsObjectManager.Create("Wall " + instanceIndexCount.ToString() + instanceIndexName);
            objectRoot.AddPhysicsObject(objectBase);
            objectBase.Shape = shape;
            objectBase.UserTagStr = shapeName;
            objectBase.Material.UserTagStr = "Wall";
                       
            objectBase.Integral.SetDensity(density);
            objectBase.EnableSleeping = enableSleeping;
            objectBase.EnableSleeping = false;
            objectBase.EnableBreakRigidGroup = false;


            objectRoot.InitLocalTransform.SetOrientation(ref objectOrientation);
            objectRoot.InitLocalTransform.SetScale(ref objectScale);
            objectRoot.InitLocalTransform.SetPosition(ref objectPosition);

            scene.UpdateFromInitLocalTransform(objectRoot);
        }
    }
}
